﻿using System;
using System.Collections.Generic;
using Studio;

namespace WzhAddon.Utils
{
	public class StudioUtils
	{
		public static ObjectCtrlInfo GetCurrentCharOrItem()
		{
			ObjectCtrlInfo[] selectObjectCtrl = Singleton<Studio.Studio>.Instance.treeNodeCtrl.selectObjectCtrl;
			if (selectObjectCtrl == null || selectObjectCtrl.Length == 0)
			{
				return null;
			}
			foreach (ObjectCtrlInfo objectCtrlInfo in selectObjectCtrl)
			{
				if (objectCtrlInfo is OCIChar || objectCtrlInfo is OCIItem)
				{
					return objectCtrlInfo;
				}
			}
			return null;
		}

		public static OCIChar GetCurrentChar()
		{
			ObjectCtrlInfo[] selectObjectCtrl = Singleton<Studio.Studio>.Instance.treeNodeCtrl.selectObjectCtrl;
			if (selectObjectCtrl == null || selectObjectCtrl.Length == 0) return null;

			foreach (ObjectCtrlInfo objectCtrlInfo in selectObjectCtrl)
			{
				if (objectCtrlInfo is OCIChar)
				{
					return objectCtrlInfo as OCIChar;
				}
			}
			return null;
		}
		public static List<OCICharFemale> GetFemales()
		{
			List<OCICharFemale> list = new List<OCICharFemale>();
			foreach (ObjectCtrlInfo objectCtrlInfo in Singleton<Studio.Studio>.Instance.dicObjectCtrl.Values)
			{
				if (objectCtrlInfo is OCICharFemale)
				{
					list.Add(objectCtrlInfo as OCICharFemale);
				}
			}
			return list;
		}
		public static List<OCICharMale> GetMales()
		{
			List<OCICharMale> list = new List<OCICharMale>();
			foreach (ObjectCtrlInfo objectCtrlInfo in Singleton<Studio.Studio>.Instance.dicObjectCtrl.Values)
			{
				if (objectCtrlInfo is OCICharMale)
				{
					list.Add(objectCtrlInfo as OCICharMale);
				}
			}
			return list;
		}
	}
}
